//modified drop down
var timeout = 100;
var closetimer = null;
var ddmenuitem = null;
var ddmparent = null;
var ddmparentcss = null;

function getOffsetById(id) {
	var obj = document.getElementById(id);
	return getOffset(obj);
}

function getOffset(obj) {
	var off = 0;
	while (obj != null) {
		off += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	return off;
}

//init DIV position
function initDiv(div, parent, align, setMinwidth) {
  //set left corner to left of parent object
	var left = getOffset(parent);
  //set width of drop down to width of parent if smaler
	if (setMinwidth && parent.offsetWidth > div.offsetWidth) {
		div.style.width = parent.offsetWidth + "px";
	}
  //if align right position - width difference
	if (align == "right") {
		left += (parent.offsetWidth - div.offsetWidth);
	}
	div.style.left = left + "px";
}

// open hidden layer
function mopen(id, parent, css, align, setMinwidth) {
  // cancel close timer
	mcancelclosetime();

  // close old layer
	if (ddmenuitem || ddmparent) {
		mclose();
	}

  // get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmparent = parent;
	ddmparentcss = css;
	initDiv(ddmenuitem, parent, align, setMinwidth);
	ddmenuitem.style.visibility = "visible";
	ddmparent.className = ddmparentcss;
}

// close showed layer
function mclose() {
	if (ddmenuitem) {
		ddmenuitem.style.visibility = "hidden";
	}
	ddmenuitem = null;
	if (ddmparent) {
		ddmparent.className = ddmparentcss;
	}
	ddmparent = null;
}

// go close timer
function mclosetime() {
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime() {
	if (closetimer) {
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
//document.onclick = mclose;

